package com.hfi.qinchaoalgorithm;

/**
 * @author ChangLiang
 * @date 2019/12/9
 */
public class FibonacciDemo {

    /**
     * 总执行语句数
     */
    private int count = 0;

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public int fib(int n) {

        if (n < 0) {
            throw new RuntimeException("n要为大于等于0的整数");
        }
        if (n == 0 || n == 1) {
            count++;
            return n;
        } else {
            count++;
            return fib(n - 1) + fib(n - 2);
        }
    }
}
